home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-03-12 | 23.0 KB | 1,699 lines |
- testmode = 1
-
- include "src:shadowlord.i"
-
- ; V1.01
- ; Added bigger understanding of PC box characters.
- ; Now also understands one-wide box chars, and thick corner changed to #,
- ; single corner to +.
-
- ; V1.02
- ; Added bad mode error, and error on no space between mode and the rest.
-
- ; V1.10
- ; Cut endspace.
- ; Text output.
-
- ; V1.13
- ; Percentage & size change
- ; extra lf
- ; extra cr removal in topc mode
-
- ; V1.16
- ; Faster translate routines 25% speedup in frompc
- ; 6 more in frompc
- ; New helptext.
-
- ; V1.18 11-feb
- ; Upper and lower case modes.
-
- ; V1.22 19-feb
- ; tabs to spaces
- ; 3 new pc box chars
- ; bug fixed that confused port if the end of the commandline had spaces.
- ; spaces to tabs
-
- ; V1.24 21-feb
- ; size reduced by 48
- ; bug fixed where tabconversion wasn't turned on in spacestotabs
- ; causing some strange behavior.
- ; reduced code size by making routines use same parts of code.
- ; Logic check for options
- ; 20% when quiet
-
- ; V1.25 11-mar
- ; buffer overflow bug fixed
- ; new table conversion system
- ; buffered input
- ; handles one filename differently
- ; ctrl+c detection
- ; doesn't screw up pp files
- ; 6856 -> 6636
- ; 9 new pc chars
- ; end lf removal
- ; no longer translates one space
-
- * 12-Mar-93
- * 24 days of hard coding
-
- ; during the program
- ; a0=source
- ; a1=dest
- ; a2=spacebuf
- ; a3=translation table
-
- ; d0=current char
- ; d1=load counter
- ; d2=savebyte counter
- ; d3=translation char
-
-
- if testmode=1
- lea test_comline,a0
- move.l #test_len,d0
- endc
-
- progstart:
- clr.b -1(a0,d0.l)
- move.l a0,commandstart
- move.w d0,commandlen
- add.l d0,a0
- subq.l #1,a0
- move.l a0,commandend
-
- lea dosname,a1
- moveq #0,d0
- move.l execbase,a6
- jsr openlibrary(a6)
- move.l d0,dosbase
-
- move.l dosbase,a6
- jsr output(a6)
- move.l d0,outstruct
-
- if testmode=1
- bne err_testmode
- endc
-
- move.l #text_cursoroff,d2
- moveq #5,d3
- bsr printtext
-
- move.l commandstart,a0
- tst.b (a0) ; if blank commandline, instructions
- beq helptext
- cmp.b #"?",(a0)
- beq helptext
-
- parsestart:
- cmp.b #"-",(a0)
- beq checkoption
-
- parse:
- cmp.b #" ",1(a0) ; at least one space after option
- bne err_nocomlinespace
- cmp.b #"p",(a0)
- beq frompcmode
- cmp.b #"P",(a0)
- beq topcmode
- cmp.b #"s",(a0)
- beq fromsf7mode
- cmp.b #"S",(a0)
- beq tosf7mode
- cmp.b #"u",(a0)
- beq toupcasemode
- cmp.b #"l",(a0)
- beq tolowcasemode
- cmp.b #"n",(a0)
- beq modetonull
- bra err_badmode
-
- checkoption:
- cmp.b #"n",1(a0)
- beq opt_nocutspace
- cmp.b #"?",1(a0)
- beq credits
- cmp.b #"t",1(a0)
- beq opt_tabconv
- cmp.b #"s",1(a0)
- beq opt_spaceconv
- cmp.b #"q",1(a0)
- beq opt_quietmode
- cmp.b #"b",1(a0)
- beq opt_nobuffermode
- bra err_badcomline
-
- opt_nocutspace:
- move.b #1,mode_nocutspace
- addq.l #2,a0
- bra opt_next
-
- opt_tabconv:
- tst.b tabsize
- bne err_badlogic
- move.b 2(a0),d0
- cmp.b #" ",d0
- beq opt_tabconv1
- sub.b #"0",d0
- cmp.b #9,d0
- bhi err_badcomline
- cmp.b #1,d0
- bcs err_badcomline
- bra opt_bothconv
-
- opt_tabconv1:
- move.b #8,d0
- subq.l #1,a0
- bra opt_bothconv
-
- opt_spaceconv:
- tst.b tabsize
- bne err_badlogic
- move.b 2(a0),d0
- cmp.b #" ",d0
- beq opt_spaceconv1
- sub.b #"0",d0
- cmp.b #9,d0
- bhi err_badcomline
- cmp.b #1,d0
- bcs err_badcomline
- move.b d0,spacesize
- bra opt_bothconv
-
- opt_spaceconv1:
- move.b #8,d0
- move.b d0,spacesize
- subq.l #1,a0
-
- opt_bothconv:
- move.b d0,tabsize
- addq.l #3,a0
- bra opt_next
-
- opt_quietmode:
- move.b #1,mode_quiet
- addq.l #2,a0
- bra opt_next
-
- opt_nobuffermode:
- move.b #1,mode_nobuffer
- addq.l #2,a0
-
- opt_next:
- cmp.b #" ",(a0)
- bne err_badcomline
- bsr skipspace
- cmp.l #0,a0
- beq err_badcomline
- bra parsestart
-
- frompcmode:
- move.b #1,mode
- lea table_frompc,a1
- move.l a1,table
- bra nameparse
-
- fromsf7mode:
- move.b #2,mode
- ; lea table_fromsf7,table
- bra nameparse
-
- tosf7mode:
- move.b #-2,mode
- ; lea table_tosf7,table
- bra nameparse
-
- topcmode:
- move.b #-1,mode
- ; lea table_topc,table
- bra nameparse
-
- toupcasemode:
- move.b #3,mode
- bra nameparse
-
- tolowcasemode:
- move.b #4,mode
- bra nameparse
-
- modetonull:
- move.b #5,mode
-
- nameparse:
- addq.l #1,a0
- bsr skipspace
- cmp.l #0,a0
- beq err_badcomline
- move.l a0,sourcenamestart
- bsr findend
- cmp.l #0,a0
- beq err_badcomline
- move.l a0,sourcenameend
- addq.l #1,a0
- sub.l sourcenamestart,a0
- move.l a0,sourcenamelen
-
- move.l sourcenamestart,a0
- move.l #sourcename,a1
- move.l sourcenamelen,d0
- subq.l #1,d0
- bsr removequotes
-
- copysourcename:
- move.b (a0)+,(a1)+
- dbf d0,copysourcename
- clr.b (a1)
-
- move.l sourcenameend,a0
- addq.l #1,a0
- cmp.l commandend,a0
- beq nodest
-
- bsr skipspace
- cmp.l #0,a0
- beq nodest
- move.l a0,destnamestart
- bsr findend
- cmp.l #0,a0
- beq err_badcomline
- move.l a0,destnameend
- addq.l #1,a0
- sub.l destnamestart,a0
- move.l a0,destnamelen
- move.l a0,d0
-
- move.l destnamestart,a0
- move.l #destname,a1
- subq.l #1,d0
- bsr removequotes
-
- copydestname:
- move.b (a0)+,(a1)+
- dbf d0,copydestname
- bra openfiles
-
- nodest:
- move.l #destname,a1
- move.l sourcenamestart,a0
- move.l sourcenamelen,d0
- subq.l #1,d0
- bsr removequotes
-
- copydestname1:
- move.b (a0)+,(a1)+
- dbf d0,copydestname1
-
- tst.b mode_nobuffer
- beq openfiles
-
- cmp.b #-1,mode
- beq pcsuffix
- cmp.b #-2,mode
- beq sf7suffix
-
- amigasuffix:
- lea text_amigasuf,a0
- moveq #4-1,d0
- bra addsuffix
-
- pcsuffix:
- lea text_pcsuf,a0
- moveq #3-1,d0
- bra addsuffix
-
- sf7suffix:
- lea text_sf7suf,a0
- moveq #4-1,d0
-
- addsuffix:
- move.b (a0)+,(a1)+
- dbf d0,addsuffix
-
- openfiles:
- clr.b (a1) ; end of filename
-
- tst.b mode_nobuffer
- beq openfiles1
-
- move.l #sourcename,d1
- move.l #mode_oldfile,d2
- move.l dosbase,a6
- jsr open(a6)
- move.l d0,sourcehandle
- beq err_nosource
-
- move.l sourcehandle,d1
- move.l #sourcebuf,d2
- add.l readbytes,d2
- move.l #4,d3
- move.l dosbase,a6
- jsr read(a6)
- cmp.l #4,d0
- bne openfiles2
-
- move.l sourcebuf,d0
- cmp.l #"PP20",d0
- beq err_powerpacked
-
- move.l sourcehandle,d1 ; seek back to the beginning of file
- moveq #0,d2
- moveq #offset_beginning,d3
- move.l dosbase,a6
- jsr seek(a6)
-
- move.l #destname,d1
- move.l #mode_newfile,d2
- move.l dosbase,a6
- jsr open(a6)
- move.l d0,desthandle
- beq err_nodest
-
- move.l #sourcebuf,sourcepointer
- bra readblock
-
- openfiles1:
- move.l #sourcename,d1
- move.l #access_read,d2
- move.l dosbase,a6
- jsr lock(a6)
- move.l d0,sourcelock ; error detection, 0=fail
-
- move.l sourcelock,d1
- move.l #fib,d2
- move.l dosbase,a6
- jsr examine(a6) ; error detection, 0=fail
-
- move.l #fib,a0
- move.l fib_size(a0),sourcelen
-
- lea sourcelenascii,a0
- move.l sourcelen,d0
- bsr num2ascii
- move.l a0,sourcelenasciiaddr
- move.l d0,sourcelenasciilen
-
- move.l sourcelock,d1
- move.l dosbase,a6
- jsr unlock(a6)
-
- move.l #sourcename,d1
- move.l #1005,d2
- move.l dosbase,a6
- jsr open(a6)
- move.l d0,sourcehandle
- beq err_nosource
-
- move.l sourcehandle,d1
- move.l #sourcebuf,d2
- add.l readbytes,d2
- move.l #4,d3
- move.l dosbase,a6
- jsr read(a6)
- cmp.l #4,d0
- bne openfiles2
-
- move.l sourcebuf,d0
- cmp.l #"PP20",d0
- beq err_powerpacked
-
- move.l sourcehandle,d1 ; seek back to the beginning of file
- moveq #0,d2
- moveq #offset_beginning,d3
- move.l dosbase,a6
- jsr seek(a6)
-
- openfiles2:
- move.l sourcelen,d0
- moveq #1,d1 ; public mem
- move.l execbase,a6
- jsr allocmem(a6)
- move.l d0,sourcepointer
- beq err_nomem
-
- readfile:
- move.l sourcehandle,d1
- move.l sourcepointer,d2
- add.l readbytes,d2
- move.l #10240,d3
- move.l dosbase,a6
- jsr read(a6)
- cmp.l #-1,d0
- beq err_readfail
- add.l d0,readbytes
- movem.l d0,-(a7)
- tst.b mode_quiet
- bne testread
-
- move.l #text_read,d2
- moveq #14,d3
- bsr printtext
-
- lea readascii,a0
- move.l readbytes,d0
- bsr num2ascii
-
- move.l a0,readasciiaddr
- move.l d0,readasciilen
- move.l a0,d2
- move.l d0,d3
- bsr printtext
-
- move.l #text_slash,d2
- moveq #1,d3
- bsr printtext
-
- move.l sourcelenasciiaddr,d2
- move.l sourcelenasciilen,d3
- bsr printtext
-
- move.l #text_cr,d2
- moveq #1,d3
- bsr printtext
-
- testread:
- movem.l (a7)+,d0
- tst.l d0 ; = number of bytes read
- beq readfinished
- move.l readbytes,leftbytes
-
- sub.l d0,d0
- sub.l d1,d1
- move.l execbase,a6
- jsr setsignal(a6)
-
- btst #12,d0 ; check if ^C was pressed
- bne breakpressed
-
- bra readfile
-
- readfinished:
- move.l sourcehandle,d1
- move.l dosbase,a6
- jsr close(a6)
-
- move.l #destname,d1
- move.l #1006,d2
- move.l dosbase,a6
- jsr open(a6)
- move.l d0,desthandle
- beq err_nodest
-
- bra moredata
-
- readblock:
- tst.b mode_nobuffer
- beq moredata
-
- move.l sourcehandle,d1
- move.l sourcepointer,d2
- move.l #1024,d3
- move.l dosbase,a6
- jsr read(a6)
- cmp.l #-1,d0
- beq err_readfail
- add.l d0,readbytes
- move.l d0,d1
- beq closefiles ; readbytes=0 - quit
- subq.l #1,d1
- sub.l d2,d2
- lea sourcebuf,a0
- lea destbuf,a1
- bra morecharacters
-
- moredata:
- tst.l leftbytes
- beq closefiles
- sub.l d2,d2
- cmp.l #1024,leftbytes
- bls moredata1
- sub.l #1024,leftbytes
- move.l sourcepointer,a0
- add.l inputbytes,a0
- add.l #1024,inputbytes
- move.l #1024-1,d1
- lea destbuf,a1
- bra morecharacters
-
- moredata1:
- move.l leftbytes,d0
- clr.l leftbytes
- move.l sourcepointer,a0
- add.l inputbytes,a0
- add.l d0,inputbytes
- subq.l #1,d0
- move.l d0,d1
- lea destbuf,a1
-
- morecharacters:
- move.b (a0)+,d0
- bra cutspace
-
- checknormal:
- cmp.b #-2,mode
- beq tosf7
- cmp.b #-1,mode
- beq topc
- cmp.b #2,mode
- beq fromsf7
- cmp.b #3,mode
- beq toupcase
- cmp.b #4,mode
- beq tolowcase
- cmp.b #5,mode
- beq nullmode
-
- frompc:
- cmp.b #" ",d0
- bcs translate
- cmp.b #"~",d0
- bhi translate
- bra nextchar
-
- translate:
- move.l table,a3
- tst.b d0
- beq nochar
-
- translate1:
- move.w (a3)+,d3
- beq nextchar ; 0=end of table
- cmp.b d3,d0
- beq translate2
- bra translate1
-
- translate2:
- lsr.w #8,d3
- move.b d3,d0 ; if 0=no char
- beq nochar
-
- nextchar:
- move.b d0,(a1)+
- addq.l #1,d2
- addq.w #1,col
-
- nochar:
- dbf d1,morecharacters
-
- move.l desthandle,d1 ; write the converted data ~1024 bytes
- move.l d2,d3
- add.l d2,writtenbytes
- move.l #destbuf,d2
- move.l dosbase,a6
- jsr write(a6)
- cmp.l #-1,d0
- beq err_writefail
-
- sub.l d0,d0
- sub.l d1,d1
- move.l execbase,a6
- jsr setsignal(a6)
-
- btst #12,d0 ; check if ^C was pressed
- bne endprogram5
-
- tst.b mode_quiet
- bne readblock
-
- tst.b mode_nobuffer
- beq alternateoutput
-
- move.l #text_input,d2
- moveq #15,d3
- bsr printtext
-
- lea numberbuf,a0
- move.l readbytes,d0
- bsr num2ascii
-
- move.l a0,d2
- move.l d0,d3
- bsr printtext
-
- move.l #text_output,d2
- moveq #18,d3
- bsr printtext
-
- lea numberbuf,a0
- move.l writtenbytes,d0
- bsr num2ascii
-
- move.l a0,d2
- move.l d0,d3
- bsr printtext
-
- move.l #text_cr,d2
- moveq #1,d3
- bsr printtext
-
- bra readblock
-
- alternateoutput:
- move.l #text_converted,d2
- moveq #19,d3
- bsr printtext
-
- lea numberbuf,a0
- move.l inputbytes,d0
- bsr num2ascii
-
- move.l a0,d2
- move.l d0,d3
- bsr printtext
-
- move.l #text_slash,d2
- moveq #1,d3
- bsr printtext
-
- move.l readasciiaddr,d2
- move.l readasciilen,d3
- bsr printtext
-
- move.l #text_cr,d2
- moveq #1,d3
- bsr printtext
-
- bra readblock
-
- cutspace:
- move.l spacepointer,a2
- cmp.b #" ",d0
- beq addspace
- cmp.b #9,d0 ; tab
- beq addtab
- bsr addeol
-
- tst.b mode_nocutspace
- bne cutspace2
-
- cmp.b #10,d0 ; lf
- beq cutspaces
- cmp.b #13,d0 ; cr
- beq cutspaces
-
- cutspace1:
- tst.b prespace
- bne insertprespace
- tst.l tabs
- bne linkspaces
-
- cutspace3:
- tst.l spacenumber
- bne linkspaces2
-
- cutspace4:
- cmp.b #10,d0
- beq nochar
- tst.b mode_nocutspace
- beq testforspace
-
- linkeols:
- move.l eols,d3
- bne linkeols1
- cmp.b #" ",d0
- beq nochar
- cmp.b #9,d0
- beq nochar
- bra checknormal
-
- linkeols1:
- add.l d3,d2
- subq.l #1,d3
-
- linkeols2:
- move.b #10,(a1)+
- dbf d3,linkeols2
- clr.l eols
- cmp.b #" ",d0
- beq nochar
- cmp.b #9,d0
- beq nochar
- bra checknormal
-
- testforspace:
- cmp.b #" ",d0
- beq nochar
- cmp.b #9,d0
- beq nochar
- bra linkeols
-
- cutspace2:
- cmp.b #10,d0
- beq clearcol
- cmp.b #13,d0
- beq clearcol
- bra cutspace1
-
- clearcol:
- clr.w col
- bra cutspace1
-
- addspace:
- addq.l #1,spacenumber
- move.b d0,(a2)+
- move.l a2,spacepointer
- addq.w #1,col
- bra checkconvspace
-
- addtab:
- move.b tabsize,d4 ; if tabsize is zero, just add it in
- bne tabconv ; spacebuffer
- bra addspace
-
- tabconv:
- ext.w d4
- ext.l d4
- move.w col,d3
- ext.l d3
- divu d4,d3
- swap d3
- sub.w d3,d4
- add.l d4,spacenumber
- add.w d4,col
- subq.w #1,d4
- move.b #" ",d0
-
- tabconv1:
- move.b d0,(a2)+
- dbf d4,tabconv1
- move.l a2,spacepointer
-
- checkconvspace:
- tst.b spacesize ; spacesize=0 means no space2tab
- beq cutspace4
- cmp.l #1,spacenumber ; if spacenumber<1, skip
- bcs cutspace4
- move.w col,d5
- ext.l d5
- move.l spacenumber,d3
- move.b spacesize,d4
- ext.w d4
- ext.l d4
-
- divu d4,d5 ; if column is divisible by spacesize,
- swap d5 ; go to "foundconvspace"
- tst.w d5
- beq foundconvspace
- bra cutspace4 ; otherwise just continue
-
- foundconvspace:
- cmp.l #1,spacenumber ; if only one space is won, don't
- beq foundconvspace2
- move.l #spacebuf,spacepointer
- addq.l #1,tabs
- sub.l d4,spacenumber
- bmi foundconvspace1
- bra cutspace4
-
- foundconvspace1:
- clr.l spacenumber
- bra cutspace4
-
- foundconvspace2:
- move.b #1,prespace
- move.l #spacebuf,spacepointer
- clr.l spacenumber
- bra cutspace4
-
- cutspaces:
- clr.l spacenumber
- clr.l tabs
- move.l #spacebuf,spacepointer
- clr.w col
- bra nochar
-
- addeol:
- cmp.b #10,d0
- beq addeol1
- rts
-
- addeol1:
- addq.l #1,eols
- rts
-
- linkspaces:
- tst.b mode_nocutspace
- bne linkspaces4
- bsr inserteols
-
- linkspaces4:
- move.l tabs,d3
- clr.l tabs
- add.l d3,d2 ; tabs -> bytes to be written
- subq.l #1,d3
-
- linkspaces1:
- move.b #9,(a1)+
- dbf d3,linkspaces1
- bra cutspace3
-
- linkspaces2:
- tst.b mode_nocutspace
- bne linkspaces5
- bsr inserteols
-
- linkspaces5:
- move.l spacenumber,d3
- add.l d3,d2 ; spaces -> bytes to be written
- subq.l #1,d3
- lea spacebuf,a2
- move.l a2,spacepointer
-
- linkspaces3:
- move.b (a2)+,(a1)+
- dbf d3,linkspaces3
- clr.l spacenumber
- bra cutspace4
-
- insertprespace:
- clr.b prespace
- move.b #" ",(a1)+
- addq.l #1,d2
- bra cutspace1
-
- inserteols:
- move.l eols,d3
- bne inserteols1
- rts
-
- inserteols1:
- add.l d3,d2
- subq.l #1,d3
-
- inserteols2:
- move.b #10,(a1)+
- dbf d3,inserteols2
- clr.l eols
- rts
-
- topc:
- cmp.b #"ä",d0
- beq pc_lowae
- cmp.b #"ö",d0
- beq pc_lowoe
- cmp.b #"Ä",d0
- beq pc_upae
- cmp.b #"Ö",d0
- beq pc_upoe
- cmp.b #13,d0
- beq nochar
- cmp.b #10,d0
- beq addcr
- cmp.b #0,d0
- beq nochar
- cmp.b #$1a,d0 ; ctrl+z
- beq nochar
- bra nextchar
-
- fromsf7:
- cmp.b #"{",d0
- beq ami_lowae
- cmp.b #"|",d0
- beq ami_lowoe
- cmp.b #"[",d0
- beq ami_upae
- cmp.b #"\",d0
- beq ami_upoe
- cmp.b #13,d0
- beq nochar
- cmp.b #0,d0
- beq nochar
- cmp.b #$1a,d0 ; ctrl+z
- beq nochar
- bra nextchar
-
- tosf7:
- cmp.b #"ä",d0
- beq sf7_lowae
- cmp.b #"ö",d0
- beq sf7_lowoe
- cmp.b #"Ä",d0
- beq sf7_upae
- cmp.b #"Ö",d0
- beq sf7_upoe
- cmp.b #10,d0
- beq addcr
- cmp.b #0,d0
- beq nochar
- cmp.b #$1a,d0 ; ctrl+z
- beq nochar
- bra nextchar
-
- toupcase:
- cmp.b #"ä",d0
- beq ami_upae
- cmp.b #"ö",d0
- beq ami_upoe
- cmp.b #"a",d0
- bcs nextchar
- cmp.b #"z",d0
- bhi nextchar
-
- and.b #%11011111,d0
- bra nextchar
-
- tolowcase:
- cmp.b #"Ä",d0
- beq ami_lowae
- cmp.b #"Ö",d0
- beq ami_lowoe
- cmp.b #"A",d0
- bcs nextchar
- cmp.b #"Z",d0
- bhi nextchar
-
- or.b #%100000,d0
- bra nextchar
-
- nullmode:
- cmp.b #13,d0
- beq nochar
- cmp.b #0,d0
- beq nochar
- cmp.b #$1a,d0 ; ctrl+z
- beq nochar
- bra nextchar
-
- ami_182:
- move.b #182,d0
- bra nextchar
-
- ami_231:
- move.b #231,d0
- bra nextchar
-
- ami_singleline:
- move.b #"-",d0
- bra nextchar
-
- ami_box:
- move.b #$7f,d0
- bra nextchar
-
- ami_upline:
- move.b #"|",d0
- bra nextchar
-
- ami_doubleline:
- move.b #"=",d0
- bra nextchar
-
- ami_smallcorner:
- move.b #"+",d0
- bra nextchar
-
- ami_bigcorner:
- move.b #"#",d0
- bra nextchar
-
- ami_lowae:
- move.b #"ä",d0
- bra nextchar
-
- ami_lowoe:
- move.b #"ö",d0
- bra nextchar
-
- ami_upae:
- move.b #"Ä",d0
- bra nextchar
-
- ami_upoe:
- move.b #"Ö",d0
- bra nextchar
-
- pc_lowae:
- move.b #$84,d0
- bra nextchar
-
- pc_lowoe:
- move.b #$94,d0
- bra nextchar
-
- pc_upae:
- move.b #$8e,d0
- bra nextchar
-
- pc_upoe:
- move.b #$99,d0
- bra nextchar
-
- sf7_lowae:
- move.b #"{",d0
- bra nextchar
-
- sf7_lowoe:
- move.b #"|",d0
- bra nextchar
-
- sf7_upae:
- move.b #"[",d0
- bra nextchar
-
- sf7_upoe:
- move.b #"\",d0
- bra nextchar
-
- addcr:
- move.b #13,(a1)+
- addq.l #1,d2
- bra nextchar
-
- closefiles:
- tst.b mode_nobuffer
- beq freebuffer
- bsr closesource
- bra closefiles3
-
- freebuffer:
- bsr freememory
-
- closefiles3:
- bsr closedest
-
- move.l #text_final,d2
- moveq #26,d3
- bsr printtext
-
- move.l readbytes,d1
- move.l writtenbytes,d0
-
- sub.l d1,d0
- bmi closefiles1 ; negative
-
- move.l d0,d7
- beq closefiles2 ; if zero, no sign
-
- move.l #text_possign,d2
- moveq #1,d3
- bsr printtext
- bra closefiles2
-
- closefiles1:
- neg.l d0
- move.l d0,d7
-
- move.l #text_negsign,d2
- moveq #1,d3
- bsr printtext
-
- closefiles2:
- move.l d7,d0
- lea numberbuf,a0
- bsr num2ascii
-
- move.l a0,d2
- move.l d0,d3
- bsr printtext
-
- move.l #text_doublespace,d2
- moveq #2,d3
- bsr printtext
-
- move.l writtenbytes,d0
- move.l readbytes,d1
- bsr percentage
-
- lea numberbuf,a0
- bsr num2ascii
-
- move.l a0,d2
- move.l d0,d3
- bsr printtext
-
- move.l #text_percentsign,d2
- move.l #5,d3
- bsr printtext
-
- move.l #text_lf,d2
- move.l #1,d3
- bsr printtext
- bra endprogram1
-
- helptext:
- move.l #text_helptext,d2
- move.l #len_helptext,d3
- bsr printtext
- bra endprogram1
-
- credits:
- move.l #text_credits,d2
- move.l #len_credits,d3
- bsr printtext
- bra endprogram1
-
- if testmode=1
- err_testmode:
- move.l #$ffff,d0
-
- err_testmode1:
- move.w #$f00,$dff180
- dbf d0,err_testmode1
- bra endprogram1
- endc
-
- err_nosource:
- move.l #text_nosource,d2
- moveq #28,d3
- bsr printerror
- bra endprogram1
-
- err_badcomline:
- move.l #text_badcomline,d2
- moveq #17,d3
- bsr printerror
- bra endprogram1
-
- err_nodest:
- move.l #text_nodest,d2
- moveq #33,d3
- bsr printerror
- bra endprogram2
-
- err_badmode:
- move.l #text_badmode,d2
- moveq #24,d3
- bsr printerror
- bra endprogram1
-
- err_nocomlinespace:
- move.l #text_nocomlinespace,d2
- moveq #52,d3
- bsr printerror
- bra endprogram1
-
- err_badlogic:
- move.l #text_badlogic,d2
- moveq #25,d3
- bsr printerror
- bra endprogram1
-
- err_nomem:
- move.l #text_nomemory,d2
- moveq #36,d3
- bsr printerror
- bsr closesource
- bra endprogram1
-
- err_powerpacked:
- move.l #text_powerpacked,d2
- moveq #48,d3
- bsr printerror
- bsr closesource
- bra endprogram1
-
- err_seekfail:
- move.l #text_badsource,d2
- moveq #23,d3
- bsr printerror
- bsr closesource
- bra endprogram1
-
- err_readfail:
- move.l #text_badsource,d2
- moveq #23,d3
- bsr printerror
- bsr closesource
- tst.b mode_nobuffer
- beq err_readfail1
- bsr closedest
- bra endprogram1
-
- err_readfail1:
- bsr freememory
- bra endprogram1
-
- err_writefail:
- move.l #text_baddest,d2
- moveq #18,d3
- bsr printerror
- bsr closesource
- tst.b mode_nobuffer
- beq err_writefail1
- bsr closedest
- bra endprogram1
-
- err_writefail1:
- bsr freememory
- bra endprogram1
-
- endprogram5:
- tst.b mode_nobuffer
- beq endprogram6
-
- bsr closesource
- bsr closedest
-
- move.l #destname,d1
- move.l dosbase,a6
- jsr deletefile(a6) ; error detection here
-
- move.l #text_break,d2
- moveq #20,d3
- bsr printtext
- bra endprogram1
-
- endprogram6:
- bsr closedest
- bsr freememory
-
- move.l #destname,d1
- move.l dosbase,a6
- jsr deletefile(a6) ; error detection here
-
- move.l #text_break,d2
- moveq #20,d3
- bsr printtext
- bra endprogram1
-
- breakpressed: ; source and mem open, dest not
- bsr freememory
- bsr closesource
- move.l #text_break,d2
- moveq #20,d3
- bsr printtext
- bra endprogram1
-
- endprogram3:
- bsr closedest
-
- endprogram2:
- tst.b mode_nobuffer ; closes source if nobuffer
- beq endprogram1
- bsr closesource
-
- endprogram1:
- move.l #text_cursoron,d2
- moveq #5,d3
- bsr printtext
-
- move.l execbase,a6
- move.l dosbase,a1
- jsr closelibrary(a6)
- moveq #0,d0
- rts
-
-
- **********
- ** SUBS **
- **********
-
- freememory:
- move.l sourcepointer,a1
- move.l sourcelen,d0
- move.l execbase,a6
- jsr freemem(a6)
- rts
-
- closedest:
- move.l desthandle,d1
- move.l dosbase,a6
- jsr close(a6)
- rts
-
- closesource:
- move.l sourcehandle,d1
- move.l dosbase,a6
- jsr close(a6)
- rts
-
- printerror:
- movem.l d2/d3,-(a7)
- move.l #text_error,d2
- move.l #8,d3
- bsr printtext
- movem.l (a7)+,d2/d3
- bsr printtext
- rts
-
- printtext:
- if testmode=1
- rts
- endc
-
- move.l outstruct,d1
- move.l dosbase,a6
- jsr write(a6)
- rts
-
- skipspace:
- cmp.b #" ",(a0)
- beq skipspace1
- rts
-
- skipspace1:
- addq.l #1,a0
- cmp.l commandend,a0
- bcs skipspace
- move.l #0,a0
- rts
-
- findend:
- cmp.b #'"',(a0)
- beq findend_quote
-
- findend_space:
- addq.l #1,a0
- cmp.b #" ",(a0)
- beq findend_space1
- cmp.b #0,(a0)
- beq findend_space1
- cmp.l commandend,a0
- bls findend_space
- move.l #0,a0
- rts
-
- findend_space1:
- subq.l #1,a0
- rts
-
- findend_quote:
- addq.l #1,a0
- cmp.b #'"',(a0)
- bne findend_quote1
- rts
-
- findend_quote1:
- cmp.l commandend,a0
- bls findend_quote
- move.l #0,a0
- rts
-
- removequotes:
- cmp.b #'"',(a0)
- beq removequotes1
- rts
-
- removequotes1:
- addq.l #1,a0
- subq.l #2,d0
- rts
-
- include "src:Num2ASCII-2.S"
- include "src:Percentage.S"
-
- **********
- ** DATA **
- **********
-
- section fastdata,data
-
- spacepointer:
- dc.l spacebuf
-
- table_frompc:
- dc.b $00,$0d
- dc.b $00,$1a
- dc.b $b6,$14
- dc.b $e7,$80
- dc.b $dc,$81
- dc.b "å",$83
- dc.b "ä",$84
- dc.b "Ä",$8e
- dc.b $e6,$91
- dc.b $c6,$92
- dc.b "ö",$94
- dc.b "Ö",$99
- dc.b $7f,$b0
- dc.b $7f,$b1
- dc.b $7f,$b2
- dc.b "|",$b3
- dc.b "#",$b6
- dc.b "+",$b7
- dc.b "|",$ba
- dc.b "#",$bb
- dc.b "#",$bc
- dc.b "+",$bd
- dc.b "+",$bf
- dc.b "+",$c0
- dc.b "+",$c3
- dc.b "-",$c4
- dc.b "#",$c8
- dc.b "#",$c9
- dc.b "=",$cd
- dc.b "+",$d3
- dc.b "#",$d4
- dc.b "+",$d9
- dc.b "+",$d6
- dc.b "+",$da
- dc.b "|",$dd
- dc.b "|",$de
- dc.b $b7,$f9
- dc.b $b7,$fa
- dc.b $b7,$fe
-
- dc.w 0
-
- text_helptext:
- incbin "src:Port/PortOpts1"
-
- text_credits:
- incbin "src:Port/PortOpts2"
-
- text_cursoroff:
- dc.b 27,"[0 p"
-
- text_cursoron:
- dc.b 27,"[1 p"
-
- text_error:
- dc.b "ERROR! "
-
- text_badcomline:
- dc.b "Bad commandline.",10
-
- text_nosource:
- dc.b "Could not open source file.",10
-
- text_nodest:
- dc.b "Could not open destination file.",10
-
- text_badmode:
- dc.b "Bad mode specification.",10
-
- text_nocomlinespace:
- dc.b "The mode must be separated with at least one space.",10
-
- text_badlogic:
- dc.b "Conflict in commandline.",10
-
- text_nomemory:
- dc.b "Not enough memory to load the file.",10
-
- text_powerpacked:
- dc.b "File is a PowerPacker data file, can't process.",10
-
- text_badsource:
- dc.b "Source file corrupted.",10
-
- text_baddest:
- dc.b "Can't write data.",10
-
- text_input:
- dc.b 27,"[1mInput: ",27,"[0m"
-
- text_output:
- dc.b " ",27,"[1mOutput: ",27,"[0m"
-
- text_read:
- dc.b 27,"[1mRead: ",27,"[0m"
-
- text_converted:
- dc.b 27,"[1mConverted: ",27,"[0m"
-
- text_break:
- dc.b 27,"[1m-BREAK-",27,"[0m",27,"[0K",10
-
- dosname:
- dc.b "dos.library",0
-
- text_amigasuf:
- dc.b ".AMI"
-
- text_pcsuf:
- dc.b ".PC"
-
- text_sf7suf:
- dc.b ".SF7"
-
- text_cr:
- dc.b 13
-
- text_lf:
- dc.b 10
-
- text_final:
- dc.b 27,"[1mFile size change:",27,"[0m "
-
- text_negsign:
- dc.b "-"
-
- text_possign:
- dc.b "+"
-
- text_percentsign:
- dc.b "%",27,"[0K"
-
- text_doublespace:
- dc.b " "
-
- text_slash:
- dc.b "/"
-
- if testmode=1
-
- test_comline:
- dc.b "n ram:test ram:shit3",10
-
- test_comlineend:
-
- test_len = test_comlineend-test_comline
-
- endc
-
- section fastblank,bss
-
- eols:
- ds.l 1
-
- sourcelock:
- ds.l 1
-
- readasciiaddr:
- ds.l 1
-
- sourcepointer:
- ds.l 1
-
- table:
- ds.l 1
-
- sourcelen:
- ds.l 1
-
- tabs:
- ds.l 1
-
- writtenbytes:
- ds.l 1
-
- readbytes:
- ds.l 1
-
- leftbytes:
- ds.l 1
-
- inputbytes:
- ds.l 1
-
- sourcehandle:
- ds.l 1
-
- desthandle:
- ds.l 1
-
- outstruct:
- ds.l 1
-
- destnamestart:
- ds.l 1
-
- destnameend:
- ds.l 1
-
- destnamelen:
- ds.l 1
-
- sourcenamestart:
- ds.l 1
-
- sourcenameend:
- ds.l 1
-
- sourcenamelen:
- ds.l 1
-
- commandstart:
- ds.l 1
-
- commandend:
- ds.l 1
-
- commandlen:
- ds.l 1
-
- dosbase:
- ds.l 1
-
- spacenumber:
- ds.l 1
-
- readasciilen:
- ds.l 1
-
- sourcelenasciilen:
- ds.l 1
-
- sourcelenasciiaddr:
- ds.l 1
-
- col:
- ds.w 1
-
- ; all bytedata that needs to be word-aligned here
-
- fib:
- ds.b 260
-
- mode:
- ds.b 1
-
- sourcename:
- ds.b 256
-
- destname:
- ds.b 256
-
- even
-
- sourcebuf:
- ds.b 1024
-
- destbuf:
- ds.b 9216
-
- spacebuf:
- ds.b 1024
-
- numberbuf:
- ds.b 10
-
- readascii:
- ds.b 10
-
- sourcelenascii:
- ds.b 10
-
- tabsize:
- ds.b 1
-
- spacesize:
- ds.b 1
-
- prespace:
- ds.b 1
-
- mode_case:
- ds.b 1
-
- mode_nocutspace:
- ds.b 1
-
- mode_quiet:
- ds.b 1
-
- mode_nobuffer:
- ds.b 1
-
- len_helptext = text_credits-text_helptext
- len_credits = text_cursoroff-text_credits
-